/* Copyright (c) 2002-2009 Grupo e-Gen.  All rights reserved.
 *
 * ====================================================================
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation;
 * either version 2.1 of the License, or any later version.
 * 
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
 * See the GNU Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 * MA 02111-1307 USA
 * 
 */
 
package br.com.managerprojectplugin.view;

import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.Viewer;

import br.com.managerprojectplugin.model.Usecase;

/**
 * Class: UseCaseContentProvider
 *   
 * @author Grupo e-Gen 
 * @version 1.0 (28/07/2012)
 * @since 1.0 (28/07/2012)
 */
public class UseCaseContentProvider implements ITreeContentProvider {

	@Override
	public void dispose() {
		
	}

	@Override
	public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
		
	}

	@Override
	public Object[] getElements(Object inputElement) {
		return (Object[]) inputElement;
	}

	@Override
	public Object[] getChildren(Object parentElement) {
		System.out.println("Devolve filhos");
		if (parentElement instanceof Usecase) {
			Usecase useCase = (Usecase) parentElement;
			return new Object[] {useCase.getCaseParent()};	
		}
		return null;
	}

	@Override
	public Object getParent(Object element) {
		return element;
	}

	@Override
	public boolean hasChildren(Object element) {
		System.out.println("Tem filho?");
		if (element instanceof Usecase) {
			Usecase useCase = (Usecase) element;
			if (useCase.getCaseParent() != null) { 
				return true;
			}
		}
		return false;
	}

	

}
